﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using PeoplesJukebox.Web.Enums;

namespace PeoplesJukebox.Web.ValueConverters
{
    /// <summary>
    /// Converter to return an icon image URL from an <see cref="ItemType"/>
    /// </summary>
    public class ItemTypeImageConverter : IValueConverter
    {
        /// <summary>
        /// Converts input item type to icon image URL
        /// </summary>
        /// <param name="value">Input value</param>
        /// <param name="targetType">Target type</param>
        /// <param name="parameter">Parameter</param>
        /// <param name="culture">Culture</param>
        /// <returns>Image URL</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //return appropriate image URL:
            string imageUri = null;
            ItemType type = (ItemType)value;
            switch (type)
            {
                case ItemType.Album:
                    imageUri = @"/Images/Album.png";
                    break;
                case ItemType.Artist:
                    imageUri = @"/Images/Artist.png";
                    break;
                case ItemType.Track:
                    imageUri = @"/Images/Track.png";
                    break;
            }
            return new Uri(imageUri, UriKind.Relative).ToString();
        }

        /// <summary>
        /// Not implemented
        /// </summary>
        /// <param name="value">Input value</param>
        /// <param name="targetType">Target type</param>
        /// <param name="parameter">Parameter</param>
        /// <param name="culture">Culture</param>
        /// <returns>Input value</returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return DependencyProperty.UnsetValue;
        }
    }
}
